//#include<iostream>
//#include<string.h>
//#include<algorithm>
//using  namespace std;
//struct student{
//	int yu,shu;
//}arr[10];
//bool cmp(struct student a,struct student b)
//{
//	if(a.yu==a.yu)return a.shu>a.shu;
//	else return a.yu>a.yu;
//}
//int main()
//{
//	for(int i=0;i<5;i++)scanf("%d %d",&arr[i].yu,&arr[i].shu);
//	sort(arr,arr+5,cmp);
//	for(int j=0;j<5;j++)printf("%d %d\n",arr[j].yu,arr[j].shu);
//	
//	return 0;
//}
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
struct student{
	int yu,shu;
}arr[10];
bool cmp(struct student a,struct student b)
{
	if(a.yu==b.yu) return a.shu>b.shu;
	else return a.yu>b.yu;
	  
}
int main()
{
	for(int i=0;i<5;i++)scanf("%d %d",&arr[i].yu,&arr[i].shu);
	sort(arr,arr+5,cmp);
	for(int j=0;j<5;j++)scanf("%d %d",arr[j].yu,arr[j].shu);
	
	return 0;
}
